class Solution {
public:
    int MLS(vector<int>& arr) {
        sort(arr.begin(),arr.end());
        vector<int> temp;
        for(auto &x : arr)
        {
            //去重
            if(int(temp.size())-1 < 0 || temp[temp.size()-1] != x) temp.push_back(x);
        }
        int n = temp.size();
        vector<int> dp(n,1);
        int ret = 1;
        for(size_t i = 1 ; i < n ; ++i)
        {
            dp[i] = temp[i-1] == temp[i]-1 ? dp[i-1]+1 : 1;
            ret = max(ret,dp[i]);
        }
        return ret;
    }
};